<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('发布顶岗实习')"/>
    <th:block th:include="include :: ztree-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-role-add">
        <div class="form-group">
            <label class="col-sm-3 control-label ">名称：</label>
            <div class="col-sm-8">
                <input class="form-control" id="workName" name="workName" required type="text" value="顶岗实习">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">申请要求：</label>
            <div class="col-sm-8">
                <textarea class="form-control" id="workRequire" name="workRequire" required type="text"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">申请截至时间：</label>
            <div class="col-sm-8">
                <input class="form-control" id="workOver" name="workOver" placeholder="年-月-日" required type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">作业数量：</label>
            <div class="col-sm-8">
                <input class="form-control" id="workWeeks" name="workWeeks" required type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">作业填写要求：</label>
            <div class="col-sm-8">
                <textarea class="form-control" id="workWeekly" name="workWeekly" required type="text"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">作业开始时间：</label>
            <div class="col-sm-8">
                <input class="form-control" id="workBegin" name="workBegin" placeholder="年-月-日" required type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">作业结束时间：</label>
            <div class="col-sm-8">
                <input class="form-control" id="workEnd" name="workEnd" placeholder="年-月-日" required type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">作业成绩占比(%)：</label>
            <div class="col-sm-8">
                <input class="form-control" id="pacific" name="pacific" required type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">总结成绩占比(%)：</label>
            <div class="col-sm-8">
                <input class="form-control" id="exam" name="exam" required type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<script type="text/javascript">
    var prefix = ctx + "sau/work";
    $(function () {
        $("#workOver").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        $("#workBegin").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        $("#workEnd").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    });


    function submitHandler() {
        if ($.validate.form()) {
            add();
        }
    }

    function add() {
        if ($.validate.form()) {
            var workName = $("input[name='workName']").val();
            var workRequire = $("textarea[name='workRequire']").val();
            var workOver = $("input[name='workOver']").val();
            var workWeeks = $("input[name='workWeeks']").val();
            var workWeekly = $("textarea[name='workWeekly']").val();
            var workBegin = $("input[name='workBegin']").val();
            var workEnd = $("input[name='workEnd']").val();
            var pacific = $("input[name='pacific']").val();
            var exam = $("input[name='exam']").val();
            $.ajax({
                cache: true,
                type: "POST",
                url: ctx + "sau/work/addWork",
                data: {
                    "workName": workName,
                    "workRequire": workRequire,
                    "workOver": workOver,
                    "workWeeks": workWeeks,
                    "workWeekly": workWeekly,
                    "workBegin": workBegin,
                    "workEnd": workEnd,
                    "pacific": pacific,
                    "exam": exam
                },
                async: false,
                error: function (request) {
                    $.modal.alertError("系统错误");
                },
                success: function (data) {
                    $.operate.successCallback(data);
                }
            });
        }
    }

</script>
</body>
</html>
